#include "testmainwindow.h"

void TestMainWindow::testViewBar()
{
    MainWindow mainWindow;
    QStringList expectedViews;
    expectedViews << "homepage" << "treeview";
    ViewToolbar  * viewBar = mainWindow.viewBar();
    QSignalSpy spy(viewBar, SIGNAL(viewChanged(QString,bool)));

    QList<QAction *> viewActions = viewBar->viewActions(false);
    QStringList viewActionNames;
    foreach(QAction * action, viewActions)
    {
        QTest::mouseClick(viewBar->widgetForAction(action), Qt::LeftButton);
        viewActionNames.append(action->data().toString());
    }

    QCOMPARE(viewActionNames, expectedViews);
    QCOMPARE(spy.count(), 2);
}

void TestMainWindow::testOpenLogFile()
{
    MainWindow mainWindow;
    mainWindow.openFile("testdata/tiny.log");

    TabBar * tabBar = mainWindow.tabBar();
    QCOMPARE(tabBar->tabText(tabBar->currentIndex()), QString("tiny.log"));
}

QTEST_MAIN(TestMainWindow)
